package com.heima.aliyun.config;

import com.aliyuncs.IAcsClient;
import com.heima.aliyun.AliyunGreenTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Administrator
 * @Date 2023/3/11
 **/
@Configuration
@ConditionalOnClass(IAcsClient.class)
@EnableConfigurationProperties(AliyunProperties.class)
public class AliyunGreenAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public GreenImageScan greenImageScan(AliyunProperties aliyunProperties) {
        return new GreenImageScan(aliyunProperties);
    }

    @Bean
    @ConditionalOnMissingBean
    public GreenTextScan greenTextScan(AliyunProperties aliyunProperties) {
        return new GreenTextScan(aliyunProperties);
    }

    @Bean
    @ConditionalOnMissingBean
    public AliyunGreenTemplate aliyunGreenTemplate(GreenTextScan greenTextScan, GreenImageScan greenImageScan) {
        return new AliyunGreenTemplate(greenTextScan, greenImageScan);
    }
}
